/**
 * Author:   YASUO
 * Date:     2018/8/9 11:29
 * Description:
 */
package com.rljk.common.consts;

import com.rljk.common.result.CodeMsg;
import com.rljk.exception.GlobalException;

public enum SexEnum {

    MAN(1,"男"),
    WOMAN(2,"女"),
    UNKNOWN(0,"未知")
    ;

    private int code;
    private String name;

    SexEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }


    public static String getName(int code) {
        for (SexEnum c : SexEnum.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        throw new GlobalException(CodeMsg.ENUM_NOT_FIND);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }


}
